//TODO: Make sure this works for 2 and more philosophers
#define NUM_PHILO 5

//the philosophers will go in a loop through this amount of Think Hungry Eat-Cycles
#define THE_CYCLES 3

/*
  We need to calculate the total amount of messages sent, so that
  we don't call msgrcv for a message that never comes and block
  forever.      
*/
#define COORD_RCV  NUM_PHILO * THE_CYCLES * 4 
#define COORD_SND  NUM_PHILO * THE_CYCLES * 2

//message codes
#define MSG_REQ_FORK 'r'
#define MSG_GRT_FORK 'g'
#define MSG_RET_FORK 'u'



//not necessary in PORN-OS
#define PARENT_MSG_QUEUE_ID 1337000

/*communication will only take place between the master and
  children, but the children won't communicate among each other*/

  struct msg {
    long priority;
    int philo_id_sender;
    int philo_id_receiver;
    int fork_id; //the fork we are talking about, the fork that is left of a philo has the same id has the philos philo_id
    char msg_code;
  } msg_send, msg_recv;


/*
We probably won't have a random function in the PORNOS Api, therefore this simple ul function.
A previous result can be used as new seed, so it doesn't need to be coupled to the time
this is taken from Wikipedia
*/

#define M_W 1337    /* must not be zero */
#define M_Z 3711    /* must not be zero */

 int get_random(int m_w, int m_z) {
  
  m_z = 36969 * (m_z & 65535) + (m_z >> 16);
  m_w = 18000 * (m_w & 65535) + (m_w >> 16);
  return (m_z << 16) + m_w;  /* 32-bit result */

}


